﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PlaceOrder_Shared.Extensions
{
    public static class StringExtensions
    {
        public static int ToInt32OrDefault(this string? str, int defaultValue = 0)
        {
            if (string.IsNullOrEmpty(str))
                return defaultValue;

            if (int.TryParse(str, out int result))
                return result;

            return defaultValue;
        }
    }
}
